package com.caiyigo.baihua.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Repository;

import com.caiyigo.baihua.dto.UserDto;
import com.caiyigo.baihua.model.SystemUser;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;

/**
 * @author Administrator
 * 
 */
@Repository
public class SystemUserMapperSql implements SystemUserMapper {
	private SqlSessionFactory sqlSessionFactory;

	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
		this.sqlSessionFactory = sqlSessionFactory;
	}

	public List getUserList(UserDto user, PageBounds pageBounds) {

		Map<String, Object> params = new HashMap<String, Object>();

		if (!StringUtils.isEmpty(user.getName())) {
			params.put(UserDto.FileConstant.NAME, user.getName());
		}
		if (null != user.getId()) {
			params.put(UserDto.FileConstant.ID, user.getId());
		}
		if (null != user.getStatus()) {
			params.put(UserDto.FileConstant.STATUS, user.getStatus());
		}
		if (!StringUtils.isEmpty(user.getEmail())) {
			params.put(UserDto.FileConstant.EMAIL, user.getName());
		}
		if (null != user.getRoleids()) {
			params.put(UserDto.FileConstant.ROLEIDS, user.getRoleids());
		}
		List<Object> list = null;
		SqlSession session = sqlSessionFactory.openSession();
		try {
			list = session.selectList(
					"com.caiyigo.baihua.dao.SystemUserMapper.list", params,
					pageBounds);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.close();
		}

		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.caiyigo.zoo.dao.SystemUserMapper#deleteByPrimaryKey(java.lang.Integer
	 * )
	 */
	@Override
	public int deleteByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.caiyigo.zoo.dao.SystemUserMapper#insert(com.caiyigo.zoo.model.SystemUser
	 * )
	 */
	@Override
	public int insert(SystemUser record) {
		// TODO Auto-generated method stub
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.caiyigo.zoo.dao.SystemUserMapper#insertSelective(com.caiyigo.zoo.
	 * model.SystemUser)
	 */
	@Override
	public int insertSelective(SystemUser record) {
		// TODO Auto-generated method stub
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.caiyigo.zoo.dao.SystemUserMapper#selectByPrimaryKey(java.lang.Integer
	 * )
	 */
	@Override
	public SystemUser selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.caiyigo.zoo.dao.SystemUserMapper#updateByPrimaryKeySelective(com.
	 * caiyigo.zoo.model.SystemUser)
	 */
	@Override
	public int updateByPrimaryKeySelective(SystemUser record) {
		// TODO Auto-generated method stub
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.caiyigo.zoo.dao.SystemUserMapper#updateByPrimaryKey(com.caiyigo.zoo
	 * .model.SystemUser)
	 */
	@Override
	public int updateByPrimaryKey(SystemUser record) {
		// TODO Auto-generated method stub
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.caiyigo.zoo.dao.SystemUserMapper#list()
	 */
	@Override
	public List<SystemUser> list() {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.caiyigo.zoo.dao.SystemUserMapper#batchDelete(java.lang.String[])
	 */
	@Override
	public int batchDelete(String[] ids) {
		// TODO Auto-generated method stub
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.caiyigo.zoo.dao.SystemUserMapper#selectByName(java.lang.String)
	 */
	@Override
	public SystemUser selectByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}

}
